#ifndef OSGRENDER_H
#define OSGRENDER_H

#include <QtWidgets/QWidget>

#include <osg/Switch>
#include <osgViewer/Viewer>

class OSGWidget;
class OSGRender : public osg::Referenced
{
public:
    OSGRender();

    void setWidget(OSGWidget*);

    osg::Node* computeAndRenderTexture(osg::Node* block, osg::Group* scene);
protected:
    ~OSGRender();
    void initScene();
    bool initViewer();
    void initOffscreenViewer();

    OSGWidget* mWidget;
    osg::ref_ptr<osg::Switch> mRoot;
    osg::ref_ptr<osgViewer::Viewer> mViewer;

    osg::ref_ptr<osg::Group> mOffRoot;
    osg::ref_ptr<osgViewer::Viewer> mOffViewer;
};

#endif // !OSGRENDER_H
